# include <bits/stdc++.h>

const int N=6000010,INF=0x3f3f3f3f;

inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-') f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int n,m,k;
inline int id(int x,int y){
	return (x-1)*m+y;
}

struct poi{
	int x,y;
	inline void read(void){
		x=::read(),y=::read();
		return;
	}
	poi(int _x=0,int _y=0){
		x=_x,y=_y;
		return;
	}
	inline int id(void){
		return ::id(x,y);
	}
	bool operator == (const poi &rhs) const{
		return x==rhs.x&&y==rhs.y;
	}
}s,t;
std::deque <poi> que;

char mp[N],buf[N];
int dis[N];
bool vis[N];

struct DSU{
	int f[N];
	inline void init(void){
		for(int i=1;i<=n*m+1;++i) f[i]=i;
		return;
	}
	inline int find(int x){
		return (f[x]==x)?f[x]:f[x]=find(f[x]);
	}
	inline void union_row(int x,int l,int r,poi bel,int w){
		if(x<1||x>n) return;
		l=std::max(l,1),r=std::min(r,m);
		if(l>r) return;
		int cur=find(id(x,l));
		while(cur<=id(x,r)){
//			printf("naga shi cur = %d id = %d [x=%d,l=%d,r=%d]\n",cur,id(x,r),x,l,r);
			if(dis[cur]>dis[bel.id()]+w){
				dis[cur]=dis[bel.id()]+w;
				if(w==1) que.push_back(poi((cur-1)/m+1,(cur-1)%m+1));
				if(w==0) que.push_front(poi((cur-1)/m+1,(cur-1)%m+1));
			}
			f[cur]=find(cur+1),cur=f[cur];
		}
		return;
	}
	inline void union_column(int l,int r,int y,poi bel,int w){
		if(y<1||y>m) return; 
		l=std::max(l,1),r=std::min(r,n);
		if(l>r) return;
		int cur=find(id(l,y));
		while(cur<=id(r,y)){
//			printf("naga shi\n");			
			if(dis[cur]>dis[bel.id()]+w){
				dis[cur]=dis[bel.id()]+w;
				if(w==1) que.push_back(poi((cur-1)/m+1,(cur-1)%m+1));
				if(w==0) que.push_front(poi((cur-1)/m+1,(cur-1)%m+1));
			}
			f[cur]=find(std::min(n*m+1,cur+m)),cur=f[cur];
		}
		return;
	}
	
}R[2],C[2];


inline bool val(poi pos){
	return mp[id(pos.x,pos.y)]=='.';
}
inline bool ins(int x,int y){
	return x>=1&&x<=n&&y>=1&&y<=m;
}
inline bool cont(int l,int r,int x){
	return x>=l&&x<=r;
}

inline void bfs(void){
	memset(dis,INF,sizeof(dis));
	
	if(val(s)) que.push_back(s),dis[s.id()]=0;
	else{
		for(int i=std::max(1,s.x-k+1);i<=std::min(n,s.x+k-1);++i){
			for(int j=std::max(1,s.y-k+1);j<=std::min(m,s.y+k-1);++j){
				que.push_back(poi(i,j)),dis[poi(i,j).id()]=1;
			}
		}
	}
	
//	int cnt=0;
	
	while(!que.empty()){
		poi cur=que.front();
		que.pop_front();
		
		if(vis[cur.id()]) continue;
		vis[cur.id()]=true;
		
//		printf("pwp = (x=%d,y=%d) d = %d\n",cur.x,cur.y,dis[cur.id()]);
		
		if(cur==t){
			printf("%d",dis[cur.id()]);
			exit(0);
		}
		
		bool corner=(abs(t.x-cur.x)==k&&abs(t.y-cur.y)==k);
		if(cont(cur.x-k,cur.x+k,t.x)&&cont(cur.y-k,cur.y+k,t.y)&&!corner){ // one step to the end
			R[1].union_row(t.x,t.y,t.y,cur,1);
			C[1].union_column(t.x,t.x,t.y,cur,1);
		}
		
//		int x=cur.x,y=cur.y;
		
		R[1].union_row(cur.x-k,cur.y-k+1,cur.y+k-1,cur,1);
		R[1].union_row(cur.x+k,cur.y-k+1,cur.y+k-1,cur,1);
		C[1].union_column(cur.x-k+1,cur.x+k-1,cur.y-k,cur,1);
		C[1].union_column(cur.x-k+1,cur.x+k-1,cur.y+k,cur,1);
		
		for(int i=std::max(1,cur.x-1);i<=std::min(n,cur.x+1);++i){
			for(int j=std::max(1,cur.y-1);j<=std::min(m,cur.y+1);++j){
				if(abs(i-cur.x)+abs(j-cur.y)==1&&val(poi(i,j))){
					R[0].union_row(i,j,j,cur,0);
					C[0].union_column(i,i,j,cur,0);
					R[1].union_row(i,j,j,cur,0);
					C[1].union_column(i,i,j,cur,0);
				}
			}
		}
	}
	
	return;
}

int main(void){
	freopen("stamp.in","r",stdin);
	freopen("stamp.out","w",stdout);
	
	n=read(),m=read(),k=read();	
	s.read(),t.read();
	
	for(int i=0;i<=1;++i) R[i].init(),C[i].init();
	
	for(int i=1;i<=n;++i){
		scanf("%s",buf+1);
		for(int j=1;j<=m;++j) mp[id(i,j)]=buf[j];
	}
	
	bfs();
	
	return 0;
}